import React, { Component } from "react";
import {
  StyleSheet,
  Text,
  View,
  Image,
  TouchableOpacity,
  TouchableHighlight,
  Dimensions,
  InteractionManager,
} from 'react-native';

import styles from './orderCardStyle';
import Communications from 'react-native-communications';
import api from '../../services/api';
import helper from '../util/helper';
import moment from 'moment';
import * as config from '../../constants/apiConfig';
import _ from 'lodash';
import Touch from '../global/Touch';
import Toast from 'react-native-sk-toast';
import ImagePicker from 'react-native-image-picker';
import { Navigation } from '../global/navigation/index';
import EasemobChat from '../global/EasemobChat';
import CountDownText from '../global/countDown/CountDownText';

var windowWidth = Dimensions.get('window').width;
var windowHeight = Dimensions.get('window').height;


class OrderCard extends Component {
    constructor(props) {
        super(props);
        // image不支持图片地址的拼接，需要写个map
        this.serviceTypeMap = {
            send: {
                img: require("../../../img/hk_service_send.png"),
                m: this._renderSend.bind(this),
                index: 0
            },
            buy: {
                img: require("../../../img/hk_service_buy.png"),
                m: this._renderBuy.bind(this),
                index: 1
            },
            express: {
                img: require("../../../img/hk_service_express.png"),
                m: this._renderExpress.bind(this),
                index: 2
            },
            lockkey: {
                img: require("../../../img/hk_service_lockkey.png"),
                m: this._renderLockkey.bind(this),
                index: 3
            },
            other: {
                img: require("../../../img/hk_service_other.png"),
                m: this._renderOhter.bind(this),
                index: 4
            },
            nursing: {
                img: require("../../../img/hk_service_nursing.png"),
                m: this._renderNursing.bind(this),
                index: 5
            }
        };

        this.state = {
            receiveActionDisabled: false,
            completeActionDisabled: false,
            diableSendPayLink:false,
            currentResiduTime:'00:00',
        };
        this.timer;
    }

    _sendPhone(phone) {
        Communications.phonecall(phone, true);
    }

    async _receiveOrder(info) {
        this.setState({ receiveActionDisabled: true });
        // 接单
        let res = await api.post("/order/updatestatus",{id:info.id,status:2,cancelReason:''});
        if(res.data){
            // let ownerInfo = await api.post('/housekeeper/ownerinfobyphone',{phone: info.user_phone});
            // if(ownerInfo.data){
            //     let send_text = "";
            //     let { session } = this.props;
            //
            //     if(info.service_type == 'send' || info.service_type == 'lockkey'){
            //         send_text = "您的管家"+(session && session.user.keeper_name)+"正在赶来的路上。请您耐心等待。<a href='" + config.WEB_BASE_URL + "/housekeeper/orderstatus?id="+info.id+"'>点击查看实时动态</a>";
            //     }else if (info.service_type == "buy") {
            //         send_text = "您的管家"+(session && session.user.keeper_name)+"已在路上（联系电话"+(session && session.user.phone)+"）。请您耐心等待。<a href='" + config.WEB_BASE_URL + "/housekeeper/orderstatus?id="+info.id+"'>点击查看实时动态</a>";
            //     }else if (info.service_type == "express") {
            //         send_text = "您的管家"+(session && session.user.keeper_name)+"已在取快递的路上（联系电话"+(session && session.user.phone)+"）。请您耐心等待。<a href='" + config.WEB_BASE_URL + "/housekeeper/orderstatus?id="+info.id+"'>点击查看实时动态</a>";
            //     }else if (info.service_type == "other") {
            //         send_text = "您的管家"+(session && session.user.keeper_name)+"已经前往为您服务（联系电话"+(session && session.user.phone)+"）。请您耐心等待。<a href='" + config.WEB_BASE_URL + "/housekeeper/orderstatus?id="+info.id+"'>点击查看实时动态</a>";
            //     }
            //
            //     let json = JSON.stringify({
            //                     "touser":ownerInfo.data.wxOpenId,
            //                     "msgtype":"text",
            //                     "text":
            //                     {
            //                          "content":send_text,
            //                     }
            //                     // "customservice":
            //                     // {
            //                     //     "kf_account": session && session.user.kf_account
            //                     // }
            //                 });
            //
            //     let send_res = await api.post('/wx/customsend',{json});
            // }else {
            //
            // }

            Toast.bottom("接单成功");
            let tp = this.props.topParent,
                p = this.props.parent;

            p.onLoad();
            // 更新待服务tab
            let arr = tp.getMarkNum();
            tp.updateMarkNum(0, arr[0] - 1);
            tp.updateMarkNum(1, arr[1] + 1);
            tp._notTakeListView && tp._notTakeListView.wrappedInstance.onLoad();

            // this.setState({receiveActionDisabled:false});
        }
    }

    async _getObj(info, phone) {
        var options = {
            title: "拍照获取物品照片",
            cancelButtonTitle: "取消",
            takePhotoButtonTitle: "拍照",
            chooseFromLibraryButtonTitle: "选择相册",
            permissionDenied: {
                title: "提示",
                text: "没有拍照和获取相册权限",
                reTryTitle: "重试",
                okTitle: "确定"
            },
            mediaType:"photo",
            quality: 0.8,
            maxHeight: parseInt(windowHeight*2),
            maxWidth: parseInt(windowWidth*2),
            storageOptions: {
                skipBackup: true,
                path: "images"
            }
        };
        // 照片
        ImagePicker.showImagePicker(options, response => {
            // Same code as in above section!
            console.log('test======response',JSON.stringify(response));
            if (response.error) {
                console.log("ImagePicker Error: ", response.error);
            } else {
                if (response.didCancel) {
                    console.log("User cancelled image picker");
                    return;
                }

                InteractionManager.runAfterInteractions(() => {
                    this.props.navigator.push({
                        title: "确认物品照片",
                        screen: "housekeeperapp.imagepicker",
                        backButtonTitle: "",
                        passProps: {
                            orderId: info.id,
                            orderType: info.service_type,
                            orderPhone: phone,
                            // source: "data:image/jpeg;base64," + response.data,
                            fileUri:response.uri,
                            otherServiceType:info.otherServiceType
                        },
                        navigatorStyle: {
                            tabBarHidden: true,
                            navBarTextColor: "white",
                            navBarButtonColor: "white",
                            navBarBackgroundColor: "#EA5404",
                            statusBarColor: "#EA5404",
                            navBarTitleTextCentered: true,
                            topBarElevationShadowEnabled: false
                        },
                        navigatorButtons: {
                            leftButtons: [
                                {
                                    id: "back",
                                    icon: require("../../../img/hk_back_icon.png")
                                }
                            ]
                        }
                    });
                });
            }
        });

        return false;
        //我已取货
        // let res = await api.post("/order/updatestatus",{id,status:3});
        // if(res.data){
        //     Toast.bottom("我已取货");
        //     let tp = this.props.topParent,
        //         p = this.props.parent;
        //
        //     p.onLoad();
        //     // 更新待服务tab
        //     let arr = tp.getMarkNum();
        //     tp.updateMarkNum(1, arr[1] - 1);
        //     tp.updateMarkNum(2, arr[2] + 1);
        //     tp._takedListView && tp._takedListView.wrappedInstance.onLoad();
        // }
    }

    componentWillUnmount() {
        // this.clearIndex && clearTimeout(this.clearIndex);
    }

    componentDidMount(){
        let {info} = this.props;
        if (info.serviceFee_pay_status == 1 ) {
            let endTime = moment(info.create_time).add(15,'minutes');
            let currentTime = moment();
            console.log('testcomponentWillUnmountcomponentWillUnmount',currentTime.valueOf());
            // return <Text>{currentTime.format('YYYY-MM-DD HH:mm:ss')}</Text>
            if (currentTime.isBefore(endTime)) {
                let duration = moment.duration((endTime.valueOf() - currentTime.valueOf()),'milliseconds');
                let _this = this;
                this.timer = setInterval(function(){
                    duration = moment.duration(duration.asMilliseconds() - 1000 , 'milliseconds');
                    console.log('testsetInterval',duration.asMilliseconds() >= 1000);
                    if (duration.asMilliseconds() >= 1000) {
                         _this.setState({
                            currentResiduTime:moment(duration.asMilliseconds()).format('mm:ss'),
                        })
                    }else{
                        _this.setState({
                            currentResiduTime:'00:00',
                        })
                        clearInterval(_this.timer);
                    }
                   
                    
                },1000)
                // return 
                //     <Text>{moment(endTime-currentTime).format('mm:ss')}</Text>
            }else{

            }
        }
        


        
    }

    // changeCompleteDisabled = () => {
    //     this.setState({completeActionDisabled:true})
    // }

    chooseType = (type) => {
        switch (type) {
            case "other":
                return  "其他"
            case "report":
                return  "报事"
            case "repair":
                return "报修"
            case "shops":
                return "特权"
            case "activity":
                return "活动报名"
            default:
               return  "预约办理"
        }
    }

    async _getComplete(info) {
        //我已送达
        if (info.service_type == "buy") {
            //如果是代买，需要填写商品金额后才能完成订单
            this.props.navigator.push({
                title: "商品金额",
                screen: "housekeeperapp.inputgoodsprice",
                backButtonTitle: "",
                passProps: {
                    order_info: {
                        id: info.id,
                        user_phone: info.user_phone
                    }
                },
                navigatorStyle: {
                    tabBarHidden: true,
                    navBarTextColor: 'white',
                    navBarButtonColor: 'white',
                    statusBarColor: '#EA5404',
                    navBarBackgroundColor: '#EA5404',
                    navBarTitleTextCentered: true,
                    topBarElevationShadowEnabled:false
                },
                navigatorButtons: {
                    leftButtons: [
                        {
                            id: "back",
                            icon: require("../../../img/hk_back_icon.png")
                        }
                    ]
                }
            });
            return;
        }
        if (info.service_type == "express") {
            //如果是代买，需要填写商品金额后才能完成订单
            // this.props.navigator.push({
            //     title: "完成订单",
            //     screen: "housekeeperapp.inputgoodsprice",
            //     backButtonTitle: "",
            //     passProps: {
            //         order_info: {
            //             id: info.id,
            //             user_phone: info.user_phone

            //         },
            //         info:info
            //     },
            //     navigatorStyle: {
            //         tabBarHidden: true,
            //         navBarTextColor: 'white',
            //         navBarButtonColor: 'white',
            //         statusBarColor: '#EA5404',
            //         navBarBackgroundColor: '#EA5404',
            //         navBarTitleTextCentered: true,
            //         topBarElevationShadowEnabled:false
            //     },
            //     navigatorButtons: {
            //         leftButtons: [
            //             {
            //                 id: "back",
            //                 icon: require("../../../img/hk_back_icon.png")
            //             }
            //         ]
            //     }
            // });
            this.props.navigator.push({
                title: "完成服务",
                screen: "housekeeperapp.servicecompletion",
                backButtonTitle: "",
                passProps: {
                    order_info: {
                        id: info.id,
                        user_phone: info.user_phone,
                        orderType: info.service_type,
                        status:info.status,
                    },
                    info:info,
                },
                navigatorStyle: {
                    tabBarHidden: true,
                    navBarTextColor: "white",
                    navBarButtonColor: "white",
                    statusBarColor: "#EA5404",
                    navBarBackgroundColor: "#EA5404",
                    navBarTitleTextCentered: true
                },
                navigatorButtons: {
                    leftButtons: [
                        {
                            id: "back",
                            icon: require("img/hk_back_icon.png")
                        }
                    ]
                }
            });
            return;
        }

        // 代送取照片
        if (info.service_type == "send") {
            this._getObj(info, info.user_phone);
            return;
        }

        // 如果订单为其他类型则跳转到完成服务页面
        if (info.service_type == "other" || info.service_type == "nursing") {
            this.props.navigator.push({
                title: "完成服务",
                screen: "housekeeperapp.servicecompletion",
                backButtonTitle: "",
                passProps: {
                    order_info: {
                        id: info.id,
                        user_phone: info.user_phone,
                        othertype: info.otherServiceType,
                        orderType: info.service_type,
                        needUploadImage:info.finishImages && info.finishImages.length != 0 ?false:true,
                        finishImages:info.finishImages,
                        status:info.status,
                    },
                },
                navigatorStyle: {
                    tabBarHidden: true,
                    navBarTextColor: "white",
                    navBarButtonColor: "white",
                    statusBarColor: "#EA5404",
                    navBarBackgroundColor: "#EA5404",
                    navBarTitleTextCentered: true
                },
                navigatorButtons: {
                    leftButtons: [
                        {
                            id: "back",
                            icon: require("img/hk_back_icon.png")
                        }
                    ]
                }
            });
            return;
        }

        let { session } = this.props;
        this.setState({ completeActionDisabled: true });

        let res = await api.post("/order/updatestatus", {id: info.id,status: 4,cancelReason:''});
        if (res.data) {
            // let ownerInfo = await api.post("/housekeeper/ownerinfobyphone", {
            //     phone: info.user_phone
            // });

            // // console.log("#####!!!!", ownerInfo);

            // if (ownerInfo.data) {
            //     let send_text = "";
            //     let orderTrack = await api.post("/order/tracksdetail", {
            //         id: info.id
            //     });
            //     if (orderTrack.data) {
            //         let delayTime = (
            //             (moment(orderTrack.data.order_endsend_time) -
            //                 moment(orderTrack.data.order_hkget_time)) /
            //             60000
            //         ).toFixed(0);

            //         // let { session } = this.props;
            //         let web_base_url = "";
            //         if (session && session.user && session.user.product && session.user.product.baseUrl) {
            //             console.log('test---------------000000000dddddddsaaaaaaaaasf',session.user.product);
            //             web_base_url = session.user.product.baseUrl;
            //         }else{
            //             web_base_url = config.WEB_BASE_URL;
            //         }

            //         if (info.service_type=='other' && info.otherServiceType == 'activity') {
            //             send_text =
            //                 "您的订单已完成。<a href='" +
            //                 web_base_url +
            //                 "/weichart/order?order_id=" +
            //                 info.id +
            //                 "&type=ORDER_REWARD'>评价服务</a>";
            //         }else if (info.service_type=='nursing') {
            //             send_text =
            //                 "您的订单已完成。<a href='" +
            //                 web_base_url +
            //                 "/weichart/order?order_id=" +
            //                 info.id +
            //                 "&type=ORDER_REWAR'>评价服务</a>";
            //         }else{
            //             send_text =
            //                 "您的订单已完成，耗时" +
            //                 delayTime +
            //                 "分钟。<a href='" +
            //                 web_base_url +
            //                 "/weichart/order?order_id=" +
            //                 info.id +
            //                 "&type=ORDER_REWARD'>评价服务</a>";
            //         }
                    

            //         let json = JSON.stringify({
            //                         "touser":ownerInfo.data.wxOpenId,
            //                         "msgtype":"text",
            //                         "text":
            //                         {
            //                              "content":send_text,
            //                         }
            //                         // "customservice":
            //                         // {
            //                         //     "kf_account": session && session.user.kf_account
            //                         // }
            //                     });

            //         let send_res = await api.post('/wx/customsend',{json});
            //     }

            // }else{
            //     // this.refs.toast.show('绑定的用户不存在');
            // }

            Toast.bottom("我已完成");
        }else{
            Toast.bottom("该笔订单已完成，请刷新后重试");
        }

        let tp = this.props.topParent,
            p = this.props.parent;
        p.onLoad();
        let arr = tp.getMarkNum();
        tp.updateMarkNum(2, arr[2] - 1);
    }


    async _editOrder(info) {
        let res = await api.post("/order/detail", { id: info.id });
        InteractionManager.runAfterInteractions(() => {
            this.props.navigator.push({
                title: "编辑任务",
                screen: "housekeeperapp.addorder",
                backButtonTitle: "",
                passProps: {
                    source: "edit",
                    data: res.data,
                    page: this.serviceTypeMap[info.service_type]["index"]
                },
                navigatorStyle: {
                    tabBarHidden: true,
                    navBarTextColor: 'white',
                	navBarButtonColor: 'white',
                    statusBarColor: '#EA5404',
                	navBarBackgroundColor: '#EA5404',
                    navBarTitleTextCentered: true,
                    topBarElevationShadowEnabled:false
                },
                navigatorButtons: {
                    leftButtons: [
                        {
                            id: "back",
                            icon: require("../../../img/hk_back_icon.png")
                        }
                    ]
                }
            });
        });
    }

    _openCancel(info){
        let tp = this.props.topParent;

        tp.setState({
            // open: true,
            // cur_id: info.id,
            
            turn: 0,
            service_type:info.otherServiceType,
            cancelOrderId:info.id,
            showCancelOrderDialog:true,
        });
        if (info.service_type == "shops") {
            this._refundShopMoney(info.id);
        }
    }

    async _robOrder(info){//抢单
        let p = this.props.parent;
        p._loading(true);
        let res = await api.post("/order/rob",{id:info.id});
        // showLoading();
        let tp = this.props.topParent;
            

        p._loading(true);
        if(res.cd == 1 || !res.data){
            EasemobChat.showOrderFailDialog();
            setTimeout(() =>{
                p.onLoad();
            }, 5010);

        }else{
            Toast.bottom("抢单成功");
            p.onLoad();
            let arr = tp.getMarkNum();
            tp.updateMarkNum(0, arr[0] - 1);
            tp.updateMarkNum(1, arr[1] + 1);
            tp.setState({
                topage: 1
            });
            tp._notTakeListView && tp._notTakeListView.wrappedInstance.onLoad();
        }
    }

    _dispatchOrder(info, isdispatch){
        Navigation.startDispatchActivity({'order_id': info.id, isdispatch});
    }

    _turnOrder(info){
        let tp = this.props.topParent;

        tp.setState({
            open: true,
            turn: 1,
            cur_id: info.id
        });

        
    }

    async _sendPayService(info){
        if (info.isSendPayLink == 1) {
            return;
        }
        let tp = this.props.topParent;
        tp._showLoading();

        // let p = this.props.parent;
       let result = await api.post("/order/sendPayLink",{orderId:info.id});
       tp._hideLoading();
       if (result.cd != 0) {
           Toast.bottom(result.msg);
           return;
       }
       this.setState({
            diableSendPayLink:true,
       })
       Toast.bottom("发送成功");

        let   p = this.props.parent;
        p.onLoad();
        let arr = tp.getMarkNum();
        tp.updateMarkNum(2, arr[2] - 1);

    }

    

    _renderH(info){
        let user_role = this.props.session.user && this.props.session.user.role;
        if(info.status == 0){
            if (user_role == 1) {
                return (
                    <View style={{flexDirection:  'column' , alignItems:  'center' ,marginBottom:15}}>
                        <Text style={{fontSize:24,color:'#EA5404'}}>¥{parseFloat(info.serviceFee).toFixed(2)}</Text>
                        <Text style={{fontSize:12,color:'#B5B5B5'}}>待支付服务费</Text>
                        <Text style={{
                            fontSize:13,
                            color:'#565656',
                            backgroundColor:'#FFF9D1',
                            borderRadius: 13,
                            paddingLeft:10,
                            paddingRight: 10,
                            paddingBottom:2,
                            paddingTop:2,
                            marginTop:12,
                        }}>支付倒计时{this.state.currentResiduTime}</Text>
                    </View>
                )
            }else{

            }
        }else if(info.status == 1){//已付过费  或者  已经结束的订单
            let village = this.props.session.user.village;
            return (
                <View style={styles.leftrightInfo}>
                    {/*<View style={styles.moneyLeftInfo}>
                        <Text style={styles.numStyle}>{info.order_price.toFixed(2)}</Text>
                        <Text style={styles.subStyle}>本单收入(元)</Text>
                    </View>*/}

                        {user_role==1 && village == ''?
                            <View style={{
                                flex:1,
                                flexDirection: 'column',
                                borderColor: '#CDCDCD',
                                alignItems:'center',

                            }}>
                                <View style={{
                                    flexDirection:'row',
                                    flex:1,
                                    alignItems:'flex-end'
                                }}>
                                    <Text style={{fontSize:24,color:'#EA5404'}}>{(moment(info.service_time)-moment())<0?0:((moment(info.service_time)-moment())/1000/60).toFixed(0)}</Text>
                                    <Text style={{fontSize:15,color:'#EA5404',marginBottom:3}}>分钟</Text>
                                </View>
                                <Text style={{fontSize:12,color:'#B5B5B5'}}>{info.service_type == 'send'||info.service_type == 'buy'?'离送货到达还剩':'离服务时间还剩'}</Text>
                                
                            </View>
                            // info.serviceFee_pay_status == 0?
                                
                            // :
                            // <View style={{
                            //     flexDirection:'row',
                            //     justifyContent:'center',
                            //     borderColor: 'red',
                            //     padding:15,
                            //     paddingBottom:5,
                            //     flex:1
                            // }}>
                            //     <View style={{
                            //         flex:1,
                            //         flexDirection: 'column',
                            //         borderRightWidth: StyleSheet.hairlineWidth,
                            //         borderColor: '#CDCDCD',
                            //         alignItems:'center'
                            //     }}>
                            //         <View style={{
                            //             flexDirection:'row',
                            //             flex:1,
                            //             alignItems:'flex-end'
                            //         }}>
                            //             <Text style={{fontSize:24,color:'#EA5404'}}>{(moment(info.service_time)-moment())<0?0:((moment(info.service_time)-moment())/1000/60).toFixed(0)}</Text>
                            //             <Text style={{fontSize:15,color:'#EA5404',marginBottom:3}}>分钟</Text>
                            //         </View>
                            //         <Text style={{fontSize:12,color:'#B5B5B5'}}>{info.service_type == 'send'||info.service_type == 'buy'?'离送货到达还剩':'离服务时间还剩'}</Text>
                                    
                            //     </View>
                            //     <View style={{
                            //         flex:1,
                            //         flexDirection: 'column',
                            //         alignItems:'center'
                            //     }}>
                            //         <Text style={{fontSize:24,color:'#EA5404'}}>{info.serviceFee.toFixed(2)}</Text>
                            //         <Text style={{fontSize:12,color:'#B5B5B5'}}>服务收入（元）</Text>
                            //     </View>
                            // </View>
                        :
                        info.serviceFee_pay_status == 0?
                            <View style={{
                                flex:1,
                                flexDirection: 'column',
                                borderColor: '#CDCDCD',
                                alignItems:'center',
                            }}>
                                <View style={{
                                    flexDirection:'row',
                                    flex:1,
                                    alignItems:'flex-end'
                                }}>
                                    <Text style={{fontSize:24,color:'#EA5404'}}>{(moment(info.service_time)-moment())<0?0:((moment(info.service_time)-moment())/1000/60).toFixed(0)}</Text>
                                    <Text style={{fontSize:15,color:'#EA5404',marginBottom:3}}>分钟</Text>
                                </View>
                                <Text style={{fontSize:12,color:'#B5B5B5'}}>{info.service_type == 'send'||info.service_type == 'buy'?'离送货到达还剩':'离服务时间还剩'}</Text>
                                
                            </View>
                        :
                        <View style={{
                            flexDirection:'row',
                            justifyContent:'center',
                            borderColor: 'red',
                            paddingLeft:15,
                            paddingTop: 15,
                            paddingRight:15,
                            flex:1,
                        }}>
                            <View style={{
                                flex:1,
                                flexDirection: 'column',
                                borderRightWidth: StyleSheet.hairlineWidth,
                                borderColor: '#CDCDCD',
                                alignItems:'center'
                            }}>
                                <View style={{
                                    flexDirection:'row',
                                    flex:1,
                                    alignItems:'flex-end'
                                }}>
                                    <Text style={{fontSize:24,color:'#EA5404'}}>{(moment(info.service_time)-moment())<0?0:((moment(info.service_time)-moment())/1000/60).toFixed(0)}</Text>
                                    <Text style={{fontSize:15,color:'#EA5404',marginBottom:3}}>分钟</Text>
                                </View>
                                <Text style={{fontSize:12,color:'#B5B5B5'}}>{info.service_type == 'send'||info.service_type == 'buy'?'离送货到达还剩':'离服务时间还剩'}</Text>
                                
                            </View>
                            <View style={{
                                flex:1,
                                flexDirection: 'column',
                                alignItems:'center'
                            }}>
                                <Text style={{fontSize:24,color:'#EA5404'}}>{info.order_price.toFixed(2)}</Text>
                                <Text style={{fontSize:12,color:'#B5B5B5'}}>服务收入（元）</Text>
                            </View>
                        </View>

                    }
                    
                </View>
            )
        }else if(info.status == 4){
            return(
                <View style={[styles.moneyRightInfo,{borderLeftWidth:0}]}>
                    <Text style={[styles.noMoneyText, info.isThirdParty?{}:{marginTop:0, marginBottom: 15}]}>已完成</Text>
                </View>
            )
        }else if(info.status == -1){
            return (
                <View style={[styles.moneyRightInfo,{borderLeftWidth:0}]}>
                    <Text style={[styles.noMoneyText, info.isThirdParty?{}:{marginTop:0, marginBottom: 15}]}>已取消</Text>
                </View>
            );
        } else {
            if (info.serviceFee_pay_status != 0) {
                let village = this.props.session.user.village;
                if (user_role == 1 && village == '') {
                    return (
                        <View style={{
                            flex:1,
                            flexDirection: 'column',
                            borderColor: '#CDCDCD',
                            alignItems:'center',
                            marginBottom:15,
                        }}>
                            <View style={{
                                flexDirection:'row',
                                flex:1,
                                alignItems:'flex-end'
                            }}>
                                <Text style={{fontSize:24,color:'#EA5404'}}>{(moment(info.service_time)-moment())<0?0:((moment(info.service_time)-moment())/1000/60).toFixed(0)}</Text>
                                <Text style={{fontSize:15,color:'#EA5404',marginBottom:3}}>分钟</Text>
                            </View>
                            <Text style={{fontSize:12,color:'#B5B5B5'}}>{info.service_type == 'send'||info.service_type == 'buy'?'离送货到达还剩':'离服务时间还剩'}</Text>
                            
                        </View>
                    )
                }else{
                    return ( <View style={{
                                flexDirection:'row',
                                justifyContent:'center',
                                borderColor: 'red',
                                paddingTop:15,
                                paddingLeft:15,
                                paddingRight:15,
                                flex:1,
                                marginBottom:15,
                            }}>
                                <View style={{
                                    flex:1,
                                    flexDirection: 'column',
                                    borderRightWidth: StyleSheet.hairlineWidth,
                                    borderColor: '#CDCDCD',
                                    alignItems:'center'
                                }}>
                                    <View style={{
                                        flexDirection:'row',
                                        flex:1,
                                        alignItems:'flex-end'
                                    }}>
                                        <Text style={{fontSize:24,color:'#EA5404'}}>{(moment(info.service_time)-moment())<0?0:((moment(info.service_time)-moment())/1000/60).toFixed(0)}</Text>
                                        <Text style={{fontSize:15,color:'#EA5404',marginBottom:3}}>分钟</Text>
                                    </View>
                                    <Text style={{fontSize:12,color:'#B5B5B5'}}>{info.service_type == 'send'||info.service_type == 'buy'?'离送货到达还剩':'离服务时间还剩'}</Text>
                                    
                                </View>
                                <View style={{
                                    flex:1,
                                    flexDirection: 'column',
                                    alignItems:'center'
                                }}>
                                    <Text style={{fontSize:24,color:'#EA5404'}}>{info.order_price.toFixed(2)}</Text>
                                    <Text style={{fontSize:12,color:'#B5B5B5'}}>服务收入（元）</Text>
                                </View>
                            </View>)
                }
               
            }else{
                return (
                    <View style={{
                        flex:1,
                        flexDirection: 'column',
                        borderColor: '#CDCDCD',
                        alignItems:'center',
                        marginBottom:15,
                    }}>
                        <View style={{
                            flexDirection:'row',
                            flex:1,
                            alignItems:'flex-end'
                        }}>
                            <Text style={{fontSize:24,color:'#EA5404'}}>{(moment(info.service_time)-moment())<0?0:((moment(info.service_time)-moment())/1000/60).toFixed(0)}</Text>
                            <Text style={{fontSize:15,color:'#EA5404',marginBottom:3}}>分钟</Text>
                        </View>
                        <Text style={{fontSize:12,color:'#B5B5B5'}}>{info.service_type == 'send'||info.service_type == 'buy'?'离送货到达还剩':'离服务时间还剩'}</Text>
                        
                    </View>
                )
            }
            // return (
            //     {info.serviceFee_pay_status != 0?
                    
            //     :
            //         <View style={[styles.moneyRightInfo,{borderLeftWidth:0}]}>
            //             <Text style={styles.noMoneyText}>{info.service_type == 'send'||info.service_type == 'buy'?'离送货到达还剩':'离服务时间还剩'}<Text style={{color:'#EA5404'}}>{(moment(info.service_time)-moment())<0?0:((moment(info.service_time)-moment())/1000/60).toFixed(0)}分钟</Text></Text>
            //         </View>}
            // )
        }
    }

    _renderF(info) {
        let status = info.status;
        let {order} = this.props;
        let user = this.props.session.user;
        let user_role = this.props.session.user && this.props.session.user.role;

        if(status == 0){
            // if(info.service_type=='lockkey'){//这两项暂时免费
            //     return (
            //         <Touch style={styles.actionBtnContainer} accessible={true} activeOpacity={0.7} onPress={this._dispatchOrder.bind(this, info, 1)}>
            //             <Text style={styles.actionBtn}>派单</Text>
            //         </Touch>
            //     );
            // } else {
                return (
                    <View style={{flex:2, flexDirection: 'row'}}>
                        <Touch style={[styles.editBtnContainer,{alignItems:'flex-start',marginLeft: 15}]} accessible={true} activeOpacity={0.7} onPress={this._openCancel.bind(this, info)}>
                            <Text style={[styles.editBtn,{width: 50}]}>取消</Text>
                        </Touch>
                        <Touch style={styles.actionBtnContainer} accessible={true} activeOpacity={0.7} disabled={info.isSendPayLink == 1?true:false} onPress={this._sendPayService.bind(this, info)}>
                            <Text style={info.isSendPayLink == 1?styles.actionDisablePayBtn:styles.actionEnablePayBtn} >发送支付链接</Text>
                        </Touch>
                    </View>
                );
            // }
        } else if (status == 1) {
            return (
                user_role == 1?
                    <View style={{flex:2, flexDirection: 'row'}}>
                        {
                            info.isThirdParty?
                                <Touch style={[styles.editBtnContainer,{alignItems:'flex-start', marginLeft: 15}]} accessible={true} activeOpacity={0.7} onPress={this._editOrder.bind(this, info)}>
                                    <Text style={[styles.editBtn,{width: 50}]}>修改</Text>
                                </Touch>
                            :
                                null
                        }
                        <Touch style={[styles.editBtnContainer,{alignItems:'flex-start',marginLeft: 15}]} accessible={true} activeOpacity={0.7} onPress={this._openCancel.bind(this, info)}>
                            <Text style={[styles.editBtn,{width: 50}]}>取消</Text>
                        </Touch>
                        {
                            user && user.village?
                                <Touch style={styles.actionBtnContainer} accessible={true} activeOpacity={0.7} disabled={this.state.receiveActionDisabled} onPress={this._robOrder.bind(this, info)}>
                                    <Text style={styles.actionBtn}>抢单</Text>
                                </Touch>
                            :
                                <Touch style={styles.actionBtnContainer} accessible={true} activeOpacity={0.7} disabled={this.state.receiveActionDisabled} onPress={this._dispatchOrder.bind(this, info, 1)}>
                                    <Text style={styles.actionBtn}>派单</Text>
                                </Touch>
                        }
                        

                    </View>
                :
                    (user_role==2&&info.service_type=='lockkey'?
                        null
                    :
                        <View style={{flex:1}}>
                            <Touch style={[styles.actionBtnContainer,{alignItems: 'center'}]} accessible={true} activeOpacity={0.7} disabled={this.state.receiveActionDisabled} onPress={this._robOrder.bind(this, info)}>
                                <Text style={[styles.actionBtn, {width: 150}]}>抢单</Text>
                            </Touch>
                        </View>
                    )
            );
        }else if(status == 2){//待服务
            return (
                user_role == 1?
                    <View style={{flex:2, flexDirection: 'row'}}>
                        {
                            user.village && info.createUser != user.id?
                                <View style={{flexDirection:'row'}}>
                                    <Touch style={[styles.editBtnContainer,{alignItems:'flex-start',marginLeft:15}]} accessible={true} activeOpacity={0.7} onPress={this._openCancel.bind(this, info)}>
                                        <Text style={[styles.editBtn,{width: 50}]}>取消</Text>
                                    </Touch>
                                    <Touch style={[styles.editBtnContainer,{alignItems:'flex-start',marginLeft:15}]} activeOpacity={0.7} accessible={true} onPress={this._turnOrder.bind(this, info)}>
                                        <Text style={[styles.editBtn,{width: 50}]}>转单</Text>
                                    </Touch>
                                </View>
                            :
                                <Touch style={[styles.editBtnContainer,{alignItems:'flex-start',marginLeft:15}]} accessible={true} activeOpacity={0.7} onPress={this._openCancel.bind(this, info)}>
                                    <Text style={[styles.editBtn,{width: 50}]}>取消</Text>
                                </Touch>

                        }   
                        
                        <Touch style={styles.actionBtnContainer} activeOpacity={0.7} accessible={true} onPress={this._getObj.bind(this, info)}>
                            <Text style={[styles.actionBtn,(info.service_type == 'nursing' && info.unservedCostPayStatus == 1) ? {
                                          width: 130,
                                          backgroundColor: "#dedede",
                                          borderColor: "#dedede",
                                          color: "#b5b5b5"
                                      }:{width:70}]}>{info.service_type == 'nursing' && info.unservedCostPayStatus == 1 ? '等待用户支付中' : info.service_type=='other' || info.service_type=='nursing' ?'立即服务':'我已取货'}</Text>
                        </Touch>
                            
                    </View>
                :
                    <View style={{flex:2, flexDirection: 'row'}}>
                        <Touch style={[styles.editBtnContainer,{alignItems:'flex-start',marginLeft: 15}]} accessible={true} activeOpacity={0.7} onPress={this._turnOrder.bind(this, info)}>
                            <Text style={[styles.editBtn,{width: 50}]}>转单</Text>
                        </Touch>
                        <Touch style={styles.actionBtnContainer} activeOpacity={0.7} accessible={true} onPress={this._getObj.bind(this, info)}>
                            <Text style={[styles.actionBtn,(info.service_type == 'nursing' && info.unservedCostPayStatus == 1) ? {
                                          width:130,
                                          backgroundColor: "#dedede",
                                          borderColor: "#dedede",
                                          color: "#b5b5b5"
                                      }:{width:70}]}>{info.service_type == 'nursing' && info.unservedCostPayStatus == 1 ? '等待用户支付中' : info.service_type=='other'  || info.service_type=='nursing' ?'立即服务':'我已取货'}</Text>
                        </Touch>
                    </View>
            );
        }else if(status == 3){//服务中
            let s = "";
            if (user.productKey == "HuLiZhan") {
                s = "用户";
            }else{
                s = "业主";
            }
            return (
                <TouchableOpacity
                    style={styles.actionBtnContainer}
                    accessible={true}
                    activeOpacity={0.7}
                    disabled={this.state.completeActionDisabled}
                    onPress={
                        (info.obj_pay_status == 1||info.servicePayStatus == 1) &&
                        (info.service_type == "buy" ||
                            info.service_type == "other"  || info.service_type == "nursinng")
                            ? null
                            : info.expressCostStatus == 1 && info.service_type == "express" 
                                ? null
                                : this._getComplete.bind(this, info)
                    }
                >
                    <Text
                        style={[
                            styles.actionBtn,
                            info.service_type == "buy" ||
                            info.service_type == "other" || info.service_type == "nursing"
                                ? (info.obj_pay_status == 1||info.servicePayStatus == 1)
                                    ? {
                                          width: 130,
                                          backgroundColor: "#dedede",
                                          borderColor: "#dedede",
                                          color: "#b5b5b5"
                                      }
                                    : { width: 130 }
                                : info.service_type == "express" && info.expressCostStatus == 1
                                    ? {
                                          width: 130,
                                          backgroundColor: "#dedede",
                                          borderColor: "#dedede",
                                          color: "#b5b5b5"
                                      }
                                    : {}
                        ]}
                    >
                        {info.service_type == "buy"
                            ? info.obj_pay_status == 1
                                ? "等待用户支付中"
                                : "完成并设置金额"
                            : info.service_type == "express" 
                                ? info.expressCostStatus == 1
                                  ? "业主支付快递费用中"
                                  : "我已完成"
                                : (info.service_type == "other" || info.service_type == "nursing")
                                ? info.servicePayStatus == 1
                                    ? s+"支付服务费用中"
                                    : "我已完成"
                                : "我已完成"}
                    </Text>
                </TouchableOpacity>
            );
        }
    }

    _renderNursingF(info) {
        let status = info.status;
        let {order} = this.props;
        let user = this.props.session.user;
        let user_role = this.props.session.user && this.props.session.user.role;

        if(status == 0){
            // if(info.service_type=='lockkey'){//这两项暂时免费
            //     return (
            //         <Touch style={styles.actionBtnContainer} accessible={true} activeOpacity={0.7} onPress={this._dispatchOrder.bind(this, info, 1)}>
            //             <Text style={styles.actionBtn}>派单</Text>
            //         </Touch>
            //     );
            // } else {
                return (
                    <View style={{flex:2, flexDirection: 'row'}}>
                        <Touch style={[styles.editBtnContainer,{alignItems:'flex-start',marginLeft: 15}]} accessible={true} activeOpacity={0.7} onPress={this._openCancel.bind(this, info)}>
                            <Text style={[styles.editBtn,{width: 50}]}>取消</Text>
                        </Touch>
                        <Touch style={styles.actionBtnContainer} accessible={true} activeOpacity={0.7} disabled={info.isSendPayLink == 1?true:false} onPress={this._sendPayService.bind(this, info)}>
                            <Text style={info.isSendPayLink == 1?styles.actionDisablePayBtn:styles.actionEnablePayBtn} >发送支付链接</Text>
                        </Touch>
                    </View>
                );
            // }
        } else if (status == 1) {
            return (
                user_role == 1?
                    <View style={{flex:2, flexDirection: 'row'}}>
                        {
                            info.isThirdParty?
                                <Touch style={[styles.editBtnContainer,{alignItems:'flex-start', marginLeft: 15}]} accessible={true} activeOpacity={0.7} onPress={this._editOrder.bind(this, info)}>
                                    <Text style={[styles.editBtn,{width: 50}]}>修改</Text>
                                </Touch>
                            :
                                null
                        }
                        <Touch style={[styles.editBtnContainer,{alignItems:'flex-start',marginLeft: 15}]} accessible={true} activeOpacity={0.7} onPress={this._openCancel.bind(this, info)}>
                            <Text style={[styles.editBtn,{width: 50}]}>取消</Text>
                        </Touch>
                        {
                            user && user.village?
                                <Touch style={styles.actionBtnContainer} accessible={true} activeOpacity={0.7} disabled={this.state.receiveActionDisabled} onPress={this._robOrder.bind(this, info)}>
                                    <Text style={styles.actionBtn}>抢单</Text>
                                </Touch>
                            :
                                <Touch style={styles.actionBtnContainer} accessible={true} activeOpacity={0.7} disabled={this.state.receiveActionDisabled} onPress={this._dispatchOrder.bind(this, info, 1)}>
                                    <Text style={styles.actionBtn}>派单</Text>
                                </Touch>
                        }
                        

                    </View>
                :
                    (user_role==2&&info.service_type=='lockkey'?
                        null
                    :
                        <View style={{flex:1}}>
                            <Touch style={[styles.actionBtnContainer,{alignItems: 'center'}]} accessible={true} activeOpacity={0.7} disabled={this.state.receiveActionDisabled} onPress={this._robOrder.bind(this, info)}>
                                <Text style={[styles.actionBtn, {width: 150}]}>抢单</Text>
                            </Touch>
                        </View>
                    )
            );
        }else if(status == 2){//待服务
            return (
                user_role == 1?
                    <View style={{flex:2, flexDirection: 'row'}}>
                        {
                            user.village && info.createUser != user.id?
                                <View style={{flexDirection:'row'}}>
                                    <Touch style={[styles.editBtnContainer,{alignItems:'flex-start',marginLeft:15}]} accessible={true} activeOpacity={0.7} onPress={this._openCancel.bind(this, info)}>
                                        <Text style={[styles.editBtn,{width: 50}]}>取消</Text>
                                    </Touch>
                                    <Touch style={[styles.editBtnContainer,{alignItems:'flex-start',marginLeft:15}]} activeOpacity={0.7} accessible={true} onPress={this._turnOrder.bind(this, info)}>
                                        <Text style={[styles.editBtn,{width: 50}]}>转单</Text>
                                    </Touch>
                                </View>
                            :
                                <Touch style={[styles.editBtnContainer,{alignItems:'flex-start',marginLeft:15}]} accessible={true} activeOpacity={0.7} onPress={this._openCancel.bind(this, info)}>
                                    <Text style={[styles.editBtn,{width: 50}]}>取消</Text>
                                </Touch>

                        }   
                        
                        <Touch style={styles.actionBtnContainer} activeOpacity={0.7} accessible={true} onPress={this._getObj.bind(this, info)}>
                            <Text style={[styles.actionBtn,(info.service_type == 'nursing' && info.unservedCostPayStatus == 1) ? {
                                          width: 130,
                                          backgroundColor: "#dedede",
                                          borderColor: "#dedede",
                                          color: "#b5b5b5"
                                      }:{width:70}]}>{info.service_type == 'nursing' && info.unservedCostPayStatus == 1 ? '等待用户支付中' : info.service_type=='other' || info.service_type=='nursing' ?'立即服务':'我已取货'}</Text>
                        </Touch>
                            
                    </View>
                :
                    <View style={{flex:2, flexDirection: 'row'}}>
                        <Touch style={[styles.editBtnContainer,{alignItems:'flex-start',marginLeft: 15}]} accessible={true} activeOpacity={0.7} onPress={this._turnOrder.bind(this, info)}>
                            <Text style={[styles.editBtn,{width: 50}]}>转单</Text>
                        </Touch>
                        <Touch style={styles.actionBtnContainer} activeOpacity={0.7} accessible={true} onPress={this._getObj.bind(this, info)}>
                            <Text style={[styles.actionBtn,(info.service_type == 'nursing' && info.unservedCostPayStatus == 1) ? {
                                          width:130,
                                          backgroundColor: "#dedede",
                                          borderColor: "#dedede",
                                          color: "#b5b5b5"
                                      }:{width:70}]}>{info.service_type == 'nursing' && info.unservedCostPayStatus == 1 ? '等待用户支付中' : info.service_type=='other'  || info.service_type=='nursing' ?'立即服务':'我已取货'}</Text>
                        </Touch>
                    </View>
            );
        }else if(status == 3){//服务中
            return (
                <TouchableOpacity
                    style={styles.actionBtnContainer}
                    accessible={true}
                    activeOpacity={0.7}
                    disabled={this.state.completeActionDisabled}
                    onPress={
                        info.servicePayStatus == 1
                        ? 
                            null
                        : 
                            info.autographed == 0 && info.servicePayStatus == 2
                            ?
                                this._handWritingSign.bind(this,info)
                            :
                                info.autographed == 1 && info.servicePayStatus == 0 || info.autographed == 1 && info.servicePayStatus == 2
                                ?
                                    this._getSafetyLocation.bind(this,info)
                                :
                                    this._getComplete.bind(this, info)
                    }
                >
                    <Text
                        style={[
                            styles.actionBtn,
                            info.servicePayStatus == 1 
                            ? 
                                {
                                  width: 130,
                                  backgroundColor: "#dedede",
                                  borderColor: "#dedede",
                                  color: "#b5b5b5"
                                }
                            : 
                                {}
                        ]}
                    >
                        {this._renderNursingFButton(info)}
                    </Text>
                </TouchableOpacity>
            );
        }
    }

    _renderNursingFButton(info){
        if (info.status == 3) {
            if (info.autographed == 0 && info.servicePayStatus == 0) {//完成设置金额
                return "我已完成"
            }else if (info.autographed == 0 && info.servicePayStatus == 1) {//等待支付
                return "用户支付服务费用中"
            }else if (info.autographed == 0 && info.servicePayStatus == 2) {//签名
                return "用户签名"
            }else if (info.autographed == 1 && info.servicePayStatus == 0 || info.autographed == 1 && info.servicePayStatus == 2) {//回家确认
                return "我已到家"
            }else if (info.autographed == 1 && info.servicePayStatus == 1) {
                return "用户支付服务费用中"
            }
        }else if (info.status == 4) {
            
        }
    }

    _handWritingSign(info){
        let tp = this.props.topParent;

        tp.setState({
            handSignOrderId:info.id,
            openHandSignDialog:true,
        });
    }

    async _getSafetyLocation(info){
        let { session } = this.props;

        let tp = this.props.topParent;

        // tp._showLoading();

        // Toast.bottom("222")
        this.setState({ completeActionDisabled: true });

        let res = await api.post("/order/updatestatus", {id: info.id,status: 4,cancelReason:''});
        console.log('test',res);
        if (res.data) {
            // let ownerInfo = await api.post("/housekeeper/ownerinfobyphone", {
            //     phone: info.user_phone
            // });

            // // console.log("#####!!!!", ownerInfo);

            // if (ownerInfo.data) {
            //     let send_text = "";
            //     let orderTrack = await api.post("/order/tracksdetail", {
            //         id: info.id
            //     });
            //     if (orderTrack.data) {
            //         let delayTime = (
            //             (moment(orderTrack.data.order_endsend_time) -
            //                 moment(orderTrack.data.order_hkget_time)) /
            //             60000
            //         ).toFixed(0);

            //         // let { session } = this.props;
            //         let web_base_url = "";
            //         if (session && session.user && session.user.product && session.user.product.baseUrl) {
            //             console.log('test---------------000000000dddddddsaaaaaaaaasf',session.user.product);
            //             web_base_url = session.user.product.baseUrl;
            //         }else{
            //             web_base_url = config.WEB_BASE_URL;
            //         }


            //         send_text =
            //             "您的订单已完成。<a href='" +
            //             web_base_url +
            //             "/weichart/order?order_id=" +
            //             info.id +
            //             "&type=ORDER_REWAR'>评价服务</a>";

                    

            //         let json = JSON.stringify({
            //                         "touser":ownerInfo.data.wxOpenId,
            //                         "msgtype":"text",
            //                         "text":
            //                         {
            //                              "content":send_text,
            //                         }
            //                         // "customservice":
            //                         // {
            //                         //     "kf_account": session && session.user.kf_account
            //                         // }
            //                     });

            //         let send_res = await api.post('/wx/customsend',{json});
            //     }

            // }else{
            //     // this.refs.toast.show('绑定的用户不存在');
            // }

            Toast.bottom("我已完成");
        }else{
            Toast.bottom("该笔订单已完成，请刷新后重试");
        }
        // tp._hideLoading();
        let p = this.props.parent;
        p.onLoad();
        let arr = tp.getMarkNum();
        tp.updateMarkNum(2, arr[2] - 1);
    }

    _splitContent(serviceContent){
        let s = serviceContent.split("元。");
        if (s.length>1) {
            return s[0]+"元。"
        }else{
            return serviceContent;
        }
        
        
    }

    _renderIconService(info){
        console.log('_renderIconService',info);
        if(info.isThirdParty){
            return (

                    <View style={styles.thirdContainer}>
                        <Image style={styles.thirdIconBg} source={require("../../../img/order_third_part_icon.png")}>
                            <Text style={styles.thirdIconText}>第三方服务</Text>
                        </Image>
                        {info.isVipOrder == 1 ? <Image source={require('../../../img/vip.png')} style={styles.underThirdVipIcon} resizeMode={Image.contain}/>:null}
                    </View>
                    

            )
        }else{
            // return null;
            return <View style={{height:0.1,width:0.1}}></View>;
        }
    }

    _renderIconMinuteOrder(info){
        let user_role = this.props.session.user && this.props.session.user.role;
        let time = info.turnMinute + '分钟';
        // if(info.turnMinute >= 1000){
        //     time = (info.turnMinute / 60).toFixed(0) + '小时';
        // }

        if(info.turnMinute>0 && user_role == 1 && info.status <= 1){
            return (
                <View style={styles.thirdContainer}>
                    <Image style={styles.thirdIconBg} source={require("../../../img/order_third_part_icon.png")}>
                        <Text style={styles.thirdIconText} numberOfLines={1}>{time + "前发起转单"}</Text>
                    </Image>
                </View>
            )
        }else{
            // return null;
            return <View style={{height:0.1,width:0.1}}></View>;
        }
    }

    _getServiceFeeCountDownTime(createTime){
        let endTime = moment(createTime).add(15,'minutes');
        let currentTime = moment();
        // return <Text>{currentTime.format('YYYY-MM-DD HH:mm:ss')}</Text>
        if (currentTime.isBefore(endTime)) {
            return 
                <Text>{moment(endTime-currentTime).format('mm:ss')}</Text>
                    // <CountDownText
                    //     style={{color:'red'}}
                    //     countType='seconds'
                    //     ref='countDownText'
                    //     afterEnd={() => {this.setState({interval:false})}}
                    //     timeLeft={59}
                    //     step={-1}
                    //     startText={moment(endTime-currentTime).format('mm:ss')}
                    //     endText='00:00:00'
                    //     auto={false}
                    //     intervalText={this._refreshCodeText.bind(this)}
                    // />

        }else{
            return <Text>00:00</Text>
        }
    }

    _settingMoney(info){
        console.log('test',info);
        this.props.navigator.push({
                title: "支付金额",
                screen: "housekeeperapp.inputgoodsprice",
                backButtonTitle: "",
                passProps: {
                    order_info: {
                        id: info.id,
                        user_phone: info.user_phone,
                    }
                },
                navigatorStyle: {
                    tabBarHidden: true,
                    navBarTextColor: 'white',
                    navBarButtonColor: 'white',
                    statusBarColor: '#EA5404',
                    navBarBackgroundColor: '#EA5404',
                    navBarTitleTextCentered: true,
                    topBarElevationShadowEnabled:false
                },
                navigatorButtons: {
                    leftButtons: [
                        {
                            id: "back",
                            icon: require("../../../img/hk_back_icon.png")
                        }
                    ]
                }
            });
    }

    _renderService(info){
        let user_role = this.props.session.user && this.props.session.user.role;
        if(user_role == 1){
            if(info.isThirdParty){
                return (
                    <View>
                        <View style={styles.objInfo}>
                            <Text style={[styles.objTitle]}>服务方</Text>
                            <Text style={styles.objSubTitle}>{info.thirdPartyName}</Text>
                        </View>
                        <View style={styles.objInfo}>
                            <Text style={[styles.objTitle]}>服务姓名</Text>
                            <Text style={styles.objSubTitle}>{info.thirdPartyPerson?info.thirdPartyPerson:'无'}</Text>
                        </View>
                        <View style={styles.objInfo}>
                            <Text style={[styles.objTitle]}>服务手机号</Text>
                            <Text style={styles.objSubTitle}>{info.thirdPartyPhone}</Text>
                        </View>
                    </View>
                )
            }else{
                if(info.status > 1){
                    return (
                        <View>
                            <View style={styles.objInfo}>
                                <Text style={styles.objTitle}>服务方</Text>
                                <Text style={styles.objSubTitle}>管家</Text>
                            </View>
                            <View style={styles.objInfo}>
                                <Text style={styles.objTitle}>服务姓名</Text>
                                <Text style={styles.objSubTitle}>{info.keeperName}</Text>
                            </View>
                            <View style={styles.objInfo}>
                                <Text style={styles.objTitle}>服务手机号</Text>
                                <Text style={styles.objSubTitle}>{info.keeperPhone}</Text>
                            </View>
                        </View>
                    )
                }else{
                    // return null;
                    return <View style={{height:0.1,width:0.1}}></View>;
                }
            }
        }else{
            // return null;
            return <View style={{height:0.1,width:0.1}}></View>;
        }
    }

    _renderSend(info){
        let user_role = this.props.session.user && this.props.session.user.role;
        return (
            <View style={styles.sendContainer}>
                {info.isVipOrder == 1 && !info.isThirdParty ? <Image source={require('../../../img/vip.png')} style={styles.vipImage} resizeMode={Image.contain}/>:null}
                <View style={styles.moneyInfo}>{this._renderH(info)}</View>

                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>寄</Text>
                    <Text style={[styles.objSubTitle, { flex: 10 }]}>
                        {info.from_address}
                    </Text>
                </View>
                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>收</Text>
                    <Text style={[styles.objSubTitle, { flex: 10 }]}>
                        {info.to_address}
                    </Text>
                </View>
                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>备注</Text>
                    <Text style={styles.objSubTitle}>
                        {info.remarks ? info.remarks : "无"}
                    </Text>
                </View>
                {this._renderService(info)}
                {info.status==-1 || info.status==4?<View style={{height:10}}></View>:<View style={styles.btnInfo}>
                    {(user_role==0||user_role==2)&&info.status==1?null:<TouchableOpacity style={styles.phoneBtnContainer} activeOpacity={0.7} onPress={this._sendPhone.bind(this, info.user_phone)}>
                        <Image source={require('../../../img/phone_btn_icon.png')} style={styles.phoneBtn}/>
                    </TouchableOpacity>}
                    {this._renderF(info)}
                </View>}
            </View>
        );
    }

    _renderBuy(info){
        let user_role = this.props.session.user && this.props.session.user.role;
        return (
            <View style={styles.sendContainer}>
                {info.isVipOrder == 1 && !info.isThirdParty ? <Image source={require('../../../img/vip.png')} style={styles.vipImage} resizeMode={Image.contain}/>:null}
                <View style={styles.moneyInfo}>{this._renderH(info)}</View>
                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>购买物品</Text>
                    <Text style={styles.objSubTitle}>{info.obj_name}</Text>
                </View>
                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>收</Text>
                    <Text style={[styles.objSubTitle, { flex: 10 }]}>
                        {info.to_address}
                    </Text>
                </View>
                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>备注</Text>
                    <Text style={styles.objSubTitle}>
                        {info.remarks ? info.remarks : "无"}
                    </Text>
                </View>
                {this._renderService(info)}

                {info.status==-1 || info.status==4?<View style={{height:10}}></View>:<View style={styles.btnInfo}>
                    {(user_role==0||user_role==2)&&info.status==1?null:<TouchableOpacity style={styles.phoneBtnContainer} activeOpacity={0.7} onPress={this._sendPhone.bind(this, info.user_phone)}>
                        <Image source={require('../../../img/phone_btn_icon.png')} style={styles.phoneBtn}/>
                    </TouchableOpacity>}
                    {this._renderF(info)}
                </View>}
            </View>
        );
    }

    _renderExpressH(info){
        console.log('info---------------',info);
        let user_role = this.props.session.user && this.props.session.user.role;
        let village = this.props.session.user.village;
        if (info.status == 0 || info.status == -1 || info.status == 4) {//
            return null;
        }else {//
            if (user_role == 1 && village == '') {//消息中心
                return null;
            }else{
                return (
                    <View style={{
                        flexDirection:'row',
                        justifyContent:'center',
                        borderColor: 'red',
                        paddingTop:15,
                        paddingLeft:15,
                        paddingRight:15,
                        flex:1,
                        marginBottom:15,
                    }}>
                        <View style={{
                            flex:1,
                            flexDirection: 'column',
                            borderRightWidth: StyleSheet.hairlineWidth,
                            borderColor: '#CDCDCD',
                            alignItems:'center'
                        }}>
                            <View style={{
                                flexDirection:'row',
                                flex:1,
                                alignItems:'flex-end'
                            }}>
                                <Text style={{fontSize:24,color:'#EA5404'}}>{(moment(info.service_time)-moment())<0?0:((moment(info.service_time)-moment())/1000/60).toFixed(0)}</Text>
                                <Text style={{fontSize:15,color:'#EA5404',marginBottom:3}}>分钟</Text>
                            </View>
                            <Text style={{fontSize:12,color:'#B5B5B5'}}>{info.service_type == 'send'||info.service_type == 'buy'?'离送货到达还剩':'离服务时间还剩'}</Text>
                            
                        </View>
                        <View style={{
                            flex:1,
                            flexDirection: 'column',
                            alignItems:'center'
                        }}>
                            <Text style={{fontSize:24,color:'#EA5404'}}>{info.order_price.toFixed(2)}</Text>
                            <Text style={{fontSize:12,color:'#B5B5B5'}}>服务收入（元）</Text>
                        </View>
                    </View>

                    
                     // <View style={styles.moneyInfo}>
                     //    <View style={{
                     //        flex:1,
                     //        flexDirection: 'column',
                     //        alignItems:'center',
                     //        marginBottom:15,
                     //    }}>
                     //        <Text style={{fontSize:24,color:'#EA5404'}}>{info.order_price.toFixed(2)}</Text>
                     //        <Text style={{fontSize:12,color:'#B5B5B5'}}>服务收入（元）</Text>
                     //    </View>
                     // </View>
                )
            }
            
        }

        
    }

    _renderExpress(info){
        let user_role = this.props.session.user && this.props.session.user.role;
        return (
             <View style={styles.sendContainer}>
                {info.isVipOrder == 1 && !info.isThirdParty ? <Image source={require('../../../img/vip.png')} style={styles.vipImage} resizeMode={Image.contain}/>:null}
                {
                    info.status == 0 || info.status==-1||info.status==4 ?
                        <View style={styles.moneyInfo}>
                            {this._renderH(info)}
                        </View>
                    :
                    (info.turnMinute>0 && user_role == 1 && info.status <= 1?<View style={{marginTop:20}}></View>:null)
                }
                {
                    info.serviceFee_pay_status == 0 ?
                        null
                    :
                    <View>
                    {this._renderExpressH(info)}
                    </View>
                }
                
                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>地址</Text>
                    <Text style={styles.objSubTitle}>{info.to_address}</Text>
                </View>
                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>服务内容</Text>
                    <Text style={[styles.objSubTitle, { flex: 3 }]}>
                        {info.express_service_content}
                    </Text>
                </View>
                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>服务时间</Text>
                    <Text style={[styles.objSubTitle, { flex: 3 }]}>
                        {info.service_time}
                    </Text>
                </View>
                {this._renderService(info)}
                {info.status==-1 || info.status==4?<View style={{height:10}}></View>:<View style={styles.btnInfo}>
                    {(user_role==0||user_role==2)&&info.status==1?null:<TouchableOpacity style={styles.phoneBtnContainer} activeOpacity={0.7} onPress={this._sendPhone.bind(this, info.user_phone)}>
                        <Image source={require('../../../img/phone_btn_icon.png')} style={styles.phoneBtn}/>
                    </TouchableOpacity>}
                    
                    {this._renderF(info)}
                </View>}
            </View>
        );
    }

    _renderLockkey(info){
        let user_role = this.props.session.user && this.props.session.user.role;
        return (
             <View style={styles.sendContainer}>
                {info.isVipOrder == 1 && !info.isThirdParty ? <Image source={require('../../../img/vip.png')} style={styles.vipImage} resizeMode={Image.contain}/>:null}
                 {info.status==-1||info.status==4?<View style={styles.moneyInfo}>
                     {this._renderH(info)}
                 </View>:(info.turnMinute>0 && user_role == 1 && info.status <= 1?<View style={{marginTop:20}}></View>:null)}




                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>地址</Text>
                    <Text style={styles.objSubTitle}>{info.to_address}</Text>
                </View>
                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>服务内容</Text>
                    <Text style={[styles.objSubTitle, { flex: 3 }]}>
                        {info.lockkey_service_content}
                    </Text>
                </View>
                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>服务时间</Text>
                    <Text style={[styles.objSubTitle, { flex: 3 }]}>
                        {info.service_time}
                    </Text>
                </View>
                {this._renderService(info)}
                {info.status==-1 || info.status==4?<View style={{height:10}}></View>:<View style={styles.btnInfo}>
                    {(user_role==0||user_role==2)&&info.status==1?null:<TouchableOpacity style={styles.phoneBtnContainer} activeOpacity={0.7} onPress={this._sendPhone.bind(this, info.user_phone)}>
                        <Image source={require('../../../img/phone_btn_icon.png')} style={styles.phoneBtn}/>
                    </TouchableOpacity>}
                    {this._renderF(info)}
                </View>}
            </View>
        );
    }

    _renderOhter(info){
        let user_role = this.props.session.user && this.props.session.user.role;
        return (
            <View style={styles.sendContainer}>
                {info.isVipOrder == 1 && !info.isThirdParty ? <Image source={require('../../../img/vip.png')} style={styles.vipImage} resizeMode={Image.contain}/>:null}
                <View style={styles.moneyInfo}>{this._renderH(info)}</View>
                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>地址</Text>
                    <Text style={styles.objSubTitle}>{info.to_address}</Text>
                </View>
                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>服务类型</Text>
                    <Text style={[styles.objSubTitle, { flex: 3 }]}>
                        {this.chooseType(info.otherServiceType)}
                    </Text>
                </View>
                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>服务内容</Text>
                    <Text style={[styles.objSubTitle, { flex: 3 }]}>
                        {info.otherServiceTitle}
                    </Text>
                </View>
                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>服务时间</Text>
                    <Text style={[styles.objSubTitle, { flex: 3 }]}>
                        {info.service_time}
                    </Text>
                </View>

                {this._renderService(info)}
                {info.status==-1 || info.status==4?<View style={{height:10}}></View>:<View style={styles.btnInfo}>
                    {(user_role==0||user_role==2)&&info.status==1?null:<TouchableOpacity style={styles.phoneBtnContainer} activeOpacity={0.7} onPress={this._sendPhone.bind(this, info.user_phone)}>
                        <Image source={require('../../../img/phone_btn_icon.png')} style={styles.phoneBtn}/>
                    </TouchableOpacity>}
                    {this._renderF(info)}
                </View>}
            </View>
        );
    }

    _renderNursing(info){
        let user_role = this.props.session.user && this.props.session.user.role;
        return (
            <View style={styles.sendContainer}>
                {info.isVipOrder == 1 && !info.isThirdParty ? <Image source={require('../../../img/vip.png')} style={styles.vipImage} resizeMode={Image.contain}/>:null}
                <View style={styles.moneyInfo}>{this._renderH(info)}</View>
                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>地址</Text>
                    <Text style={styles.objSubTitle}>{info.to_address}</Text>
                </View>
                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>服务类型</Text>
                    <Text style={[styles.objSubTitle, { flex: 3 }]}>
                        护理服务
                    </Text>
                </View>
                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>服务内容</Text>
                    <Text style={[styles.objSubTitle, { flex: 3 }]}>
                        {info.otherServiceTitle}
                    </Text>
                </View>
                <View style={styles.objInfo}>
                    <Text style={styles.objTitle}>服务时间</Text>
                    <Text style={[styles.objSubTitle, { flex: 3 }]}>
                        {info.service_time}
                    </Text>
                </View>

                {this._renderService(info)}
                {info.status==-1 || info.status==4?<View style={{height:10}}></View>:<View style={styles.btnInfo}>
                    {(user_role==0||user_role==2)&&info.status==1?null:<TouchableOpacity style={styles.phoneBtnContainer} activeOpacity={0.7} onPress={this._sendPhone.bind(this, info.user_phone)}>
                        <Image source={require('../../../img/phone_btn_icon.png')} style={styles.phoneBtn}/>
                    </TouchableOpacity>}
                    {this._renderNursingF(info)}
                </View>}
            </View>
        );
    }

    render() {
        const { info, viewOrder } = this.props;
        console.log('test----------0000000009999999info-------======',info);
        let {cur_id} = this.state;
        return (
            <View>
                <View style={styles.cardContainer}>
                    {this._renderIconService(info)}
                    {this._renderIconMinuteOrder(info)}
    				<TouchableOpacity style={{flex:1}} activeOpacity={0.8} onPress={viewOrder.bind(this, info.id, this)}>
    					<View style={styles.card}>
    						<View style={styles.cardDetails}>
                                {this.serviceTypeMap[info.service_type]['m'](info)}
    						</View>
    					</View>
    				</TouchableOpacity>
    			</View>
                <Image source={this.serviceTypeMap[info.service_type].img} style={styles.cardImage} resizeMode={Image.contain}/>
            </View>
        );
    }
}

var connectHelper = require("../../services/connectHelper");
OrderCard = connectHelper(state => state)(OrderCard);

module.exports = OrderCard;
